classdef dotsQueryableTestable < dotsQueryable
    
    properties
        nTestDims = 5;
    end
    
    methods
        function self = dotsQueryableTestable
            self = self@dotsQueryable;
            self.latestDataTime = 0;
        end
        
        function isAvailable = checkIsAvailable(self)
            isAvailable = true;
        end
        
        function data = makeNewData(self, whatKind)
            data = zeros(self.nDimensions, 3);
            data(:,1) = [self.dimensions.ID];
            data(:,3) = self.latestDataTime + 1;
            
            if nargin < 2
                whatKind = '';
            end
            switch whatKind
                case 'max'
                    data(:,2) = [self.dimensions.maxValue];
                    
                case 'min'
                    data(:,2) = [self.dimensions.minValue];
                    
                otherwise
                    data(:,2) = [self.dimensions.neutralValue];
            end
        end
    end
    
    methods (Access = protected)
        % contrive dimension values so they go negative and positive
        function setupDimensions(self)
            for ii = 1:self.nTestDims
                self.dimensions(ii) = dotsFiniteDimension.newLinear( ...
                    -ii, ii, ii);
                self.dimensions(ii).name = sprintf('dim-%d', ii);
                self.dimensions(ii).ID = ii;
                self.dimensions(ii).neutralValue = ...
                    self.dimensions(ii).minValue;
            end
        end
        
        % make phenomenons to represent min and max each for each dimension
        function setupDefaultPhenomenons(self)
            temp = self.getPhenomenonTemplate;
            for ii = 1:self.nTestDims
                d = self.dimensions(ii);
                
                phenom = dotsPhenomenon.partition(temp, ...
                    d.name, d.minValue, '==');
                phenom.name = sprintf('%d',ii);
                self.addPhenomenonToGroup(phenom, 'min');
                
                phenom = dotsPhenomenon.partition(temp, ...
                    d.name, d.maxValue, '==');
                phenom.name = sprintf('%d',ii);
                self.addPhenomenonToGroup(phenom, 'max');
            end
        end
    end
end